module Visualizer::Test::Zoom

import vis::Render;
import vis::Figure;
import Number;
import String;
import List;

data ClassList = Class(str name, int ModuleSize);
data VisualizationTree = JavaPackage(str name, int pkSize, int nrOfClass, int LOC, list[VisualizationTree] children, list[ClassList] classes);

public VisualizationTree Generate()
{
  return JavaPackage("bla", 2, 3, 10, [JavaPackage("bli", 4, 5, 20, [], []), JavaPackage("blo", 6, 7, 40, [JavaPackage("la", 8, 9, 60, [], []), JavaPackage("li", 10, 11, 80, [], [])], [])], []);
}

public FProperty popup(int pkSize, int nrOfClass, int LOC){ 
  return mouseOver(
  	ellipse(
  		text(
  		    "Package size: \t\t\t" + toString(pkSize) + "\nAmount of classes:\t\t" + toString(nrOfClass) + "\nLOC:\t\t\t\t" + toString(LOC)), fillColor("lightyellow"), 
            resizable(false), top(), right(), std(gap(5))
        )
    ); 
}

public Figure GetTree(VisualizationTree x)
{
  list[Figure] f = [];
  
  if( size(x.children) != 0 )
  {
	  for (i <- [0..(size(x.children)-1)])
	  {
	    f = f +[GetTree(x.children[i])];
	  }
  }
  
  if( size(f) > 0 )
  {
	  return tree( box(text("Package: " + x.name), popup(x.pkSize, x.nrOfClass, x.LOC), std(gap(10))),
	  			   [tree(box(text("Subpackages"), std(gap(10))), f, std(gap(20)))],
	  			   resizable(false), std(gap(20)), manhattan(true)
	  );
  }
  return tree( box(text("Package: " + x.name), popup(x.pkSize, x.nrOfClass, x.LOC), std(gap(10))),
  			   f,
  			   resizable(false), std(gap(20)), manhattan(true)
  );
}

public void PrintTree(VisualizationTree x)
{
  render(GetTree(x));
}








 

public void show(str pkName, int pkSize, int nrOfClass, int LOC)
{
  t2 = tree(box(text("Package: " + pkName), popup(pkSize, nrOfClass, LOC), std(gap(5)), left()),
          [ box(text("Packages"), std(gap(5))),
     	    box(text("Top 10 CC methods"), std(gap(5))),
     	    box(text("Top 10 god classes"), std(gap(5)))
     	  ],
          std(size(50)), std(gap(20)), manhattan(true)
    	);
  render(t2);
}